package com.longrise.android.request;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;

public class WXUserRequest {
	
	private static WXUserRequest mWxUserRequest = null;
	
	public static WXUserRequest getInstance(){
		if(mWxUserRequest == null ){
			synchronized (WXUserRequest.class) {
				if(mWxUserRequest == null){
					mWxUserRequest = new WXUserRequest();
				}
			}
		}
		return mWxUserRequest;
	}
	
	public JSONObject getWX(String getUrl) throws Exception{
		JSONObject josnResult = null;
		HttpGet httpGet = new HttpGet(getUrl);
		httpGet.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000);
		HttpResponse response = new DefaultHttpClient().execute(httpGet);
		if(response.getStatusLine().getStatusCode() == 200){
			HttpEntity httpEntity = response.getEntity();
			josnResult = new JSONObject(EntityUtils.toString(httpEntity, "UTF-8"));
		}
		return josnResult;
	}
}
